﻿using System.ComponentModel.DataAnnotations;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;

namespace YaAppoint.EntityFrameworkCore;

public static class YaAppointEfCoreEntityExtensionMappings
{
    private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();

    public static void Configure()
    {
        YaAppointGlobalFeatureConfigurator.Configure();
        YaAppointModuleExtensionConfigurator.Configure();

        OneTimeRunner.Run(() =>
        {
            // Identity额外属性到数据库的映射

            ObjectExtensionManager.Instance.AddOrUpdateProperty<IdentityUser, string>(
                "JobNumber",
                options=>
                {
                    options.Attributes.Add(new MaxLengthAttribute(64));
                }
            );

            ObjectExtensionManager.Instance.AddOrUpdateProperty<IdentityUser, string>(
                "IdNumber",
                options =>
                {
                    options.Attributes.Add(new MaxLengthAttribute(50));
                }
            );

            ObjectExtensionManager.Instance.AddOrUpdateProperty<IdentityUser, string>(
               "OuterNumber",
               options =>
               {
                   options.Attributes.Add(new MaxLengthAttribute(50));
               }
            );

            ObjectExtensionManager.Instance.MapEfCoreProperty<IdentityUser, string>
            (
                "Description",
                (entityBuilder, propertyBuilder) =>
                {
                   
                }
            );
        });
    }
}
